package controller;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import pojo.Info;
import service.InfoManager;

@Controller
public class InfoController {
	@Resource(name="manager")
	private InfoManager manager;
	
	
	@RequestMapping(value="/regist", method=RequestMethod.POST)
	public String regist(Info info){
		System.out.println(info.getId()+"\t"+info.getName()+"\t"+info.getPwd()+"\t"+info.getAge());
		manager.addInfo(info);
		return "login";
	}
	
	@RequestMapping(value="/login", method=RequestMethod.POST)
	public String login(String name, String pwd){
		System.out.println(name+"\t"+pwd);
		Info info = manager.findInfo(name);
		if(pwd.equals(info.getPwd())){
			return "suc";
		}else{
			return "fail";
		}
		
	}

}
